<?php
@ob_start();
@session_start();
include('../function/config.php');
include("../connect/connect.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery-autocomplete/lib/jquery.js"></script>
<script type="text/javascript" src="jquery-autocomplete/jquery.autocomplete.js"></script>
<script type="text/javascript" src="jquery-autocomplete/lib/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="jquery-autocomplete/lib/jquery.ajaxQueue.js"></script>
<script type="text/javascript" src="jquery-autocomplete/lib/thickbox-compressed.js"></script>
<link rel="stylesheet" href="jquery-autocomplete/lib/thickbox.css" />
<link rel="stylesheet" href="jquery-autocomplete/jquery.autocomplete.css"/>
<title><?php echo $config['title'];?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
<link rel="shortcut icon" href="../image/Letter-T.ico" />
  <?php
$Query = "SELECT list_name_name FROM list_name ORDER BY list_name_count ASC";
$objQuery = mysql_query($Query) or die("Error Query [" . $Query . "]");
	while($row = mysql_fetch_assoc($objQuery)){
		$line1[]=array($row["list_name_name"]);
	}
?> 
<script type="text/javascript">
$(document).ready(function(){

	var str_month = <?php echo json_encode($line1).';'; ?>

	$("#name").autocomplete( str_month , {
		mustMatch: false,
		autoFill: false,
		matchContains: true,
		});

})
</script>
</head>
<?php
if(trim($_POST["name"]) != "")
{
	$AddName = mysql_query("INSERT INTO list_name (list_name_name,list_name_count) VALUES ('".$_POST["name"]."','1') ON DUPLICATE KEY UPDATE list_name_count = list_name_count+1");
	
	$Query = "INSERT INTO  member_non_session (member_non_session_code,member_non_session_name,member_non_session_table) VALUES ('".$_GET["code"]."','".$_POST["name"]."','".$_SESSION["table"]."') ON DUPLICATE KEY UPDATE member_non_session_code='".$_GET["code"]."',member_non_session_name='".$_POST["name"]."'";
	$objQuery = mysql_query($Query);

	$Query1 = "DELETE FROM member_session WHERE member_session_table = '".$_SESSION["table"]."'";
	$objQuery1 = mysql_query($Query1);
	
	$Query2 = mysql_query("UPDATE table_status SET table_status_sv='0' WHERE table_status_table = '".$_SESSION["table"]."'");
/*
	$_SESSION["name_ar"]=$_POST["table"];
	session_write_close();
*/
	header("location:manage_list.php");
	exit();
}
?>
<script>
function setFocus(){
document.form1.name.focus();
}

</script>
<body onload="setFocus()">
<p align="center"><h2 align="center">กรุณาใส่ชื่อผู้ซื้อ</h2>
<form id="form1" name="form1" method="post" action="">
  <div align="center">
  <p>
  <input name="name" type="text" id="name" style="height:40px; width:300px; font-size:30px; color:#0000FF"  autocomplete="off"/> 
  </p>
  <p>
  <input type="submit" name="Submit" value="ตกลง" style="height:40px; width:100px; font-size:25px" />
  <input name="cancel" type="button" id="cancel" value="ยกเลิก" style="height:40px; width:100px; font-size:25px" onclick="window.location='manage_list.php'" />
  </p>
  </div>
</form>
</p>
</body>

</html>
